﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OConf.IBLL;
using OConf.Model;
using OConf.Model.Common;
using OConf.Model.RequestInput.ConfigInfo;
using System.Collections.Generic;

namespace OConf.API.Controllers
{
    [Authorize]
    [Route("api/[Controller]/[Action]")]
    [ApiController]
    public class ConfigInfoController : ControllerBase
    {
        private readonly IConfigInfoBLL _configInfoBLL;

        public ConfigInfoController(IConfigInfoBLL configInfoBLL)
        {
            _configInfoBLL = configInfoBLL;
        }

        /// <summary>
        /// 新增项目信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ReturnData<bool> AddConfigInfo([FromBody] AddConfigInfoInput input)
        {
            return _configInfoBLL.AddConfigInfo(input);
        }

        /// <summary>
        /// 编辑项目信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ReturnData<bool> EditConfigInfo([FromBody] EditConfigInfoInput input)
        {
            return _configInfoBLL.EditConfigInfo(input);
        }

        /// <summary>
        /// 删除配置信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ReturnData<bool> DeleteConfigInfo([FromBody] DeleteConfigInfoInput input)
        {
            return _configInfoBLL.DeleteConfigInfo(input);
        }

        /// <summary>
        /// 还原配置信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ReturnData<bool> RestoreConfigInfo([FromBody] RestoreConfigInfoInput input)
        {
            return _configInfoBLL.RestoreConfigInfo(input);
        }

        /// <summary>
        /// 根据NameSpaceID获取配置信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ReturnData<List<ConfigInfoModel>> GetConfigInfoByNameSpaceID([FromQuery] GetConfigInfoListInput input)
        {
            return _configInfoBLL.GetConfigInfoByNameSpaceID(input);
        }

        /// <summary>
        /// 获取配置文件信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ReturnData<List<ConfigFileInfo>> GetConfigFileInfo([FromQuery] GetConfigFileInfoInput input)
        {
            return _configInfoBLL.GetConfigFileInfo(input);
        }
    }
}